<?php

	class Mod_giveaways_pesquisa extends CI_Model{

		function __construct()
		{
			parent::__construct();
		}


		function pesquisaGiveaways()
		{
			$query_str1 = "SELECT * FROM giveaway";

			$result1 = $this->db->query($query_str1);

			return $result1->result();
		}

		function pesquisaGiveawaysUser($username)
		{
			$query_str2 = "SELECT * FROM giveaway WHERE g_autor = '".$username."'";

			$result1 = $this->db->query($query_str2);

			return $result1->result();
		}

		function n_inscritos($id_user)
		{
			$query_str2 = "SELECT * FROM inscricoes WHERE u_id = $id_user";

			$result1 = $this->db->query($query_str2);

			return ($result1->num_rows());
		}

		function n_ganhos($id_user)
		{
			$query_str2 = "SELECT * FROM giveaway WHERE g_winner = $id_user";

			$result1 = $this->db->query($query_str2);

			return ($result1->num_rows());
		}

	}

?>